﻿#include "ssLightMaterial.h"
#include "../../system/ssLightSystem.h"

namespace StarSeeker
{

ssLightMaterial::ssLightMaterial()
{
	m_diffuseCoefficient.Set(0.353f, 0.365f, 0.7f);
	m_specularCoefficient.Set(1.0f, 1.0f, 1.0f);
	m_ambientCoefficient.Set(0.176f, 0.196f, 0.38f);
	m_diffuse.BindData(SS_GL_UNIFORM_VEC, "inDiffuseCoefficient");
	m_specular.BindData(SS_GL_UNIFORM_VEC, "inSpecularCoefficient");
	m_ambient.BindData(SS_GL_UNIFORM_VEC, "inAmbientCoefficient");
}

ssLightMaterial::~ssLightMaterial()
{
}

void ssLightMaterial::SetShaderUniform()
{
	ssMaterial::SetShaderUniform();
	if (m_pShader)
	{
		for (i32 i = 0; i < MAX_LIGHT_NUM; ++i)
		{
			if (ssLightSystem::s_light[i].type > 0)
			{
				ssLightSystem::s_light[i].uflightType.Use(m_pShader, &ssLightSystem::s_light[i].type, 1);
				ssLightSystem::s_light[i].uflightPos.Use(m_pShader, ssLightSystem::s_light[i].lightPos.m, 3);
				ssLightSystem::s_light[i].uflightIntensity.Use(m_pShader, &ssLightSystem::s_light[i].lightIntensity, 1);
			}
		}
		m_diffuse.Use(m_pShader, m_diffuseCoefficient.m, 3);
		m_specular.Use(m_pShader, m_specularCoefficient.m, 3);
		m_ambient.Use(m_pShader, m_ambientCoefficient.m, 3);
	}
}

}
